<!--
 * @Author: 贾博林 11457230+jabolin@user.noreply.gitee.com
 * @Date: 2022-10-21 14:40:08
 * @LastEditors: 贾博林 11457230+jabolin@user.noreply.gitee.com
 * @LastEditTime: 2022-10-24 10:10:22
 * @FilePath: \v-shop\code\src\views\myaside.vue
 * @Description: 侧边栏
-->
<template>
  <el-aside :width="iscollapse ? '64px' : '200px'">
    <p @click="iscollapse = !iscollapse">|||</p>
    <el-menu default-active="2" router :collapse="iscollapse" background-color="#333744" text-color="#fff" unique-opened
      :collapse-transition="false">
      <el-submenu :index="'' + item.id" v-for="(item, key) in menus" :key="item.id">
        <template slot="title">
          <i :class="icon[key]"></i>
          <span>{{ item.authName }}</span>
        </template>
        <el-menu-item :index="'/' + ite.path" v-for="ite in item.children" :key="ite.id">
          <i class="el-icon-menu"></i>
          <span>{{ ite.authName }}</span>
        </el-menu-item>
      </el-submenu>
    </el-menu>
  </el-aside>
</template>
  
<script>
import { menus } from '../http/api';
export default {
  data() {
    return {
      iscollapse: false,
      menus: [],
      icon: [
        'el-icon-user-solid',
        'el-icon-upload',
        'el-icon-s-goods',
        'el-icon-s-order',
        'el-icon-s-platform'
      ]


    };
  },
  created() {
    this.getdata();
  },
  methods: {
    getdata() {
      menus().then((res => {
        // console.log(res);
        this.menus = res.data.data
      }))
    },
  },
};
</script>
  
<style  scoped>
p {
  margin: 0;
  padding: 0;
  text-align: center;
  cursor: pointer;
  background-color: #4a5064;
  letter-spacing: 5px;
}
</style>